<?php

namespace addons\fzdc\controller;

use app\admin\model\fzdc\app\Url;
use app\admin\model\fzdc\message\Push;
use app\admin\model\fzdc\rotation\Rotation;
use app\admin\model\User;
use app\common\controller\Api;
use think\Log;
use think\Queue;

class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /*
     * 获取轮播图列表
     */
    public function list()
    {
        $type = $this->request->post('type') ?? 1;      // 类型
        $count = $this->request->post('count') ?? 10;    // 返回数量
        $where = "";
        if ($type) {
            $where = array('type' => $type);
        }
        $data = Rotation::where("state", 1)->where($where)->where("deletetime", null)->field("id,image,url,type")->order("weigh", "desc")->limit($count)->select()
            ->each(function ($item) {
                $item->image = cdnurl($item->image, true);
                $item->url = Url::get($item->url)['url'];
            });
        $this->success('返回成功', $data);
    }

}
